package pl.edu.agh.neurony;

import java.awt.Dimension;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.SwingUtilities;

import pl.edu.agh.neurony.exceptions.NeuronNetException;
import pl.edu.agh.neurony.gui.NetCreationWindow;
import pl.edu.agh.neurony.gui.NeuralGraph;
import pl.edu.agh.neurony.gui.customSwingComponents.EtchedBorderPanel;

public class Main {
	
	private static final int WINDOW_HEIGHT = 690;
	private static final int WINDOW_WIDTH = 366;
	private static final int WIDTH_OFFSET = 13;
	private static final int HEIGHT_OFFSET = 5;

	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			@Override
			public void run() {
				createAndShowGUI();
			}
		});
	}

    private static void createAndShowGUI() {
        JFrame graphFrame = new JFrame("Net Structure");
        graphFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
        graphFrame.setLocation(WINDOW_WIDTH + WIDTH_OFFSET, HEIGHT_OFFSET);
        graphFrame.setResizable(false);
        
		try {
			graphFrame.setContentPane(NeuralGraph.getInstance(true));
		} catch (NeuronNetException e) {
			graphFrame.add(new EtchedBorderPanel(new JLabel("Fatal error: Couldn't initialize graph"), "ERROR"));
		}
        
        graphFrame.pack();
        graphFrame.setVisible(true);
        
        JFrame frame = new JFrame("Neural Net AGH Project");
        frame.setMinimumSize(new Dimension(WINDOW_WIDTH, WINDOW_HEIGHT));
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 
        NetCreationWindow netCreationWindow = new NetCreationWindow();
        netCreationWindow.setOpaque(true);
        frame.setContentPane(netCreationWindow);
 
        frame.pack();
        frame.setVisible(true);
    }
}
